		<div class="row">
	    <div class="col-xs-12">
        <div class="box box-primary">
          <div class="box-header">
            <h3 class="box-title">Edit Data Peserta</h3>
          </div><!-- /.box-header -->
          <?php echo form_open('kepesertaan_peserta/update', array('role' => 'form', 'id' => 'form'));
          if(!empty($list)){
          ?>
          <div class="box-body">				        
            <!-- text input -->
            <div class="row">
            	<div class="col-sm-6">
            		<div class="form-group">
							    <label>NIK</label>
							    <input type="hidden" name="kd_peserta" value="<?= $list['kd_peserta'];?>">
							    <input class="form-control input-sm" name="nik" id="nik" type="hidden" value="<?= $list['nik'];?>">
						      <input class="form-control input-sm" name="nik_disabled" type="text" value="<?= $list['nik'];?>" disabled>
							  </div>
		            <div class="form-group">
							    <label>Nama</label>
						      <input class="form-control input-sm" name="nama" id="nama" type="text" value="<?= $list['nama'];?>" placeholder="Nama Peserta">
							  </div>
							  <div class="form-group">
							    <label>Tempat Lahir</label>
						      <input class="form-control input-sm" name="tempat_lahir" id="tempat_lahir" type="text" value="<?= $list['tempat_lahir'];?>" placeholder="Tempat Lahir">
							  </div>
							  <div class="form-group">
							    <label>Tanggal Lahir</label>
						      <input class="form-control input-sm" style="background: #fff" name="tgl_lahir" id="tgl_lahir" type="text" value="<?= id_date($list['tgl_lahir']);?>" placeholder="Tanggal Lahir" readonly>
							  </div>
							  <div class="form-group">
							    <label>Jenis Kelamin</label>
						      <select class="form-control input-sm" name="jk" id="jk">
							      <?php
							      	if($list['jk'] == 'P'){
							      		$sl = "";
							      		$sp = "selected";
							      	}else{
							      		$sl = "selected";
							      		$sp = "";
							      	}
							      ?>
						      	<option value="L" <?php echo $sl; ?>>Laki-laki</option>
						      	<option value="P" <?php echo $sp; ?>>Perempuan</option>
						      </select>
							  </div>
							  <div class="form-group">
							    <label>Golongan Darah</label>
						      <select class="form-control input-sm" name="golongan_darah" id="golongan_darah">
						      	<?php
							      	if($list['golongan_darah'] == 'A'){
							      		$so  = "";
							      		$sa  = "selected";
							      		$sb  = "";
							      		$sab = "";
							      	}else if($list['golongan_darah'] == 'B'){
							      		$so  = "";
							      		$sa  = "";
							      		$sb  = "selected";
							      		$sab = "";
							      	}else if($list['golongan_darah'] == 'AB'){
							      		$so  = "";
							      		$sa  = "";
							      		$sb  = "";
							      		$sab = "selected";
							      	}else if($list['golongan_darah'] == 'O'){
							      		$so  = "selected";
							      		$sa  = "";
							      		$sb  = "";
							      		$sab = "";
							      	}
							      ?>
						      	<option value=""> - - Pilih Golongan Darah - - </option>
						      	<option value="O" <?php echo $so; ?>>O</option>
						      	<option value="A" <?php echo $sa; ?>>A</option>
						      	<option value="B" <?php echo $sb; ?>>B</option>
						      	<option value="AB" <?php echo $sab; ?>>AB</option>
						      </select>
							  </div>
							  <div class="form-group">
							    <label>Nama Ibu</label>
						      <input class="form-control input-sm" name="ibu" id="ibu" type="text" value="<?= $list['ibu'];?>" placeholder="Nama Ibu">
							  </div>
							  <div class="form-group">
							    <label>Nama Ayah</label>
						      <input class="form-control input-sm" name="ayah" id="ayah" type="text" value="<?= $list['ayah'];?>" placeholder="Nama Ayah">
							  </div>
							  <div class="form-group">
							    <label>Agama</label>
						      <select class="form-control input-sm" name="agama" id="agama">
						      	<option value=""> - - Pilih Agama - - </option>
						      	<?php
						      		foreach ($agama as $value) {
						      			if($value['id_agama'] == $list['id_agama']){
						      				$s = "selected";
						      			}else{
						      				$s = "";
						      			}
						      			echo "<option value='".$value['id_agama']."' $s>".$value['agama']."</option>";
						      		}
						      	?>
						      </select>
							  </div>
							  <div class="form-group">
							    <label>Status Nikah</label>
						      <select class="form-control input-sm" name="status_nikah" id="status_nikah">
						      	<option value=""> - - Pilih Status Nikah - - </option>
						      	<?php
						      		foreach ($status_nikah as $value) {
						      			if($value['id_status_nikah'] == $list['id_status_nikah']){
						      				$s = "selected";
						      			}else{
						      				$s = "";
						      			}
						      			echo "<option value='".$value['id_status_nikah']."' $s>".$value['status_nikah']."</option>";
						      		}
						      	?>
						      </select>
							  </div>
	            </div>
	            <div class="col-sm-6">
	            	<div class="form-group">
							    <label>Pendidikan</label>
						      <select class="form-control input-sm" name="pendidikan" id="pendidikan">
						      	<option value=""> - - Pilih Pendidikan - - </option>
						      	<?php
						      		foreach ($pendidikan as $value) {
						      			if($value['id_pendidikan'] == $list['id_pendidikan']){
						      				$s = "selected";
						      			}else{
						      				$s = "";
						      			}
						      			echo "<option value='".$value['id_pendidikan']."' $s>".$value['pendidikan']."</option>";
						      		}
						      	?>
						      </select>
							  </div>
							  <div class="form-group">
							    <label>Pekerjaan</label>
						      <select class="form-control input-sm" name="pekerjaan" id="pekerjaan">
						      	<option value=""> - - Pilih Pekerjaan - - </option>
						      	<?php
						      		foreach ($pekerjaan as $value) {
						      			if($value['id_pekerjaan'] == $list['id_pekerjaan']){
						      				$s = "selected";
						      			}else{
						      				$s = "";
						      			}
						      			echo "<option value='".$value['id_pekerjaan']."' $s>".$value['pekerjaan']."</option>";
						      		}
						      	?>
						      </select>
							  </div>
							  <div class="form-group">
							    <label>SHDK</label>
						      <select class="form-control input-sm" name="shdk" id="shdk">
							      <option value=""> - - Pilih SHDK - - </option>
							      <?php
						      		foreach ($shdk as $value) {
						      			if($value['id_shdk'] == $list['id_shdk']){
						      				$s = "selected";
						      			}else{
						      				$s = "";
						      			}
						      			echo "<option value='".$value['id_shdk']."' $s>".$value['shdk']."</option>";
						      		}
						      	?>
						      </select>
							  </div>
							  <div class="form-group">
							    <label>Nomer Kartu Keluarga</label>
						      <input class="form-control input-sm" name="kd_kk" id="kd_kk" type="text" value="<?= $list['kd_kk'];?>" disabled>
							  </div>
							  <div class="form-group">
							    <label>Alamat</label>
						      <input class="form-control input-sm" name="alamat" id="alamat" type="text" value="<?= $list['alamat'];?>" disabled>
							  </div>
							  <div class="form-group">
							    <label>RT</label>
						      <input class="form-control input-sm" name="rt" id="rt" type="text" value="<?= $list['rt'];?>" disabled>
							  </div>
							  <div class="form-group">
							    <label>RW</label>
						      <input class="form-control input-sm" name="rw" id="rw" type="text" value="<?= $list['rw'];?>" disabled>
							  </div>
							  <div class="form-group">
							    <label>Kelurahan</label>
						      <select class="form-control input-sm" name="kelurahan" id="kelurahan" disabled>
						      	<option value=""> - - Pilih Kelurahan - - </option>
						      	<?php
						      		foreach ($kelurahan as $value) {
						      			if($value['kd_kelurahan'] == $list['kd_kelurahan']){
						      				$s = "selected";
						      			}else{
						      				$s = "";
						      			}
						      			echo "<option value='".$value['kd_kelurahan']."' $s>".$value['kelurahan']."</option>";
						      		}
						      	?>
						      </select>
							  </div>
							  <div class="form-group">
							    <label>Jenis Peserta</label>
						      <select class="form-control input-sm" name="jenis_peserta" id="jenis_peserta">
							      <option value=""> - - Pilih Jenis Peserta - - </option>
							      <?php
						      		foreach ($jenis_peserta as $value) {
						      			if($value['id_jenis_peserta'] == $list['id_jenis_peserta']){
						      				$s = "selected";
						      			}else{
						      				$s = "";
						      			}
						      			echo "<option value='".$value['id_jenis_peserta']."' $s>".$value['jenis_peserta']."</option>";
						      		}
						      	?>
						      </select>
							  </div>
							  <div class="form-group">
							    <label>Foto</label>
							    <a data-toggle="modal" href="#myModal">
							    	<span class="pull-right">
							    		<i class="glyphicon glyphicon-camera" style="color: #3C8DBC"></i>
							    	</span>
							    </a>
						      <input name="foto" type="file">
							  </div>
	            </div>
	          </div>
          </div>		                   
          <div class="box-footer">
            <button type="submit" class="btn btn-sm btn-primary btn-flat"><i class="fa fa-floppy-o"></i> Simpan</button>
          </div>
          <?php if (isset($_SERVER['HTTP_REFERER'])) {?>
            <input type="hidden" name="redirurl" value="<?php echo $_SERVER['HTTP_REFERER'];?>" />
          <?php }?>
				<?php
				}else{
				echo "Tidak ada data";	
				}
				echo form_close();
				?>
	        </div><!-- /.box -->                            
	    </div>
		</div>

		<script>
		$("#form").validate({
			rules: {
				agama: {
					required: true
				},
			}
		});
		</script>

		<script type="text/javascript">
			function kd_kk(){
				var send_data = {
						kd_kk: $("#kd_kk").val(),
						<?php echo $this->security->get_csrf_token_name(); ?>: "<?php echo $this->security->get_csrf_hash(); ?>",
					};

				$.ajax({
					type: "POST",
					url: "<?php echo base_url() ?>kepesertaan_peserta/get_keluarga",
					data: send_data,
					cache: false,
					dataType: 'json',
					success: function(msg){
						$("#alamat").val(msg.alamat);
						$("#rt").val(msg.rt);
						$("#rw").val(msg.rw);
						$("#kelurahan").val(msg.kelurahan);
					}
				});
			}
		</script>

		<script type="text/javascript">
      $(document).ready(function(){
        $('#tgl_lahir').datepicker({
          dateFormat: "dd/mm/yy",
          changeMonth: true,
          changeYear: true
        });
      });
    </script>

    <script>
			$("#form").validate({
				rules: {
					nama: {
						required: true
					},
					tempat_lahir: {
						required: true
					},
					tanggal_lahir: {
						required: true
					},
					jk: {
						required: true
					},
					agama: {
						required: true
					},
					status_nikah: {
						required: true
					},
					pendidikan: {
						required: true
					},
					pekerjaan: {
						required: true
					},
					shdk: {
						required: true
					},
					kelurahan: {
						required: true
					},
					ibu: {
						required: true
					},
					ayah: {
						required: true
					},
					jenis_peserta: {
						required: true
					},
				}
			});
		</script>